package com.example.amap.ui.map.ui.navigation

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.amap.ui.map.ui.page.PageMain
import com.example.amap.ui.map.ui.page.PageSearch
import com.example.amap.ui.map.ui.page.constant.PAGE_MAP_MAIN
import com.example.amap.ui.map.ui.page.constant.PAGE_MAP_SEARCH

@Composable
fun AppNavigation() {
    val navController = rememberNavController()
    NavHost(
        navController = navController,
        startDestination = PAGE_MAP_MAIN,
        modifier = Modifier.padding(start = 32.dp, top = 64.dp, end = 32.dp)
    ) {
        composable(PAGE_MAP_MAIN) {
            PageMain(onSearchBarClick = {
                navController.navigate(PAGE_MAP_SEARCH)
            })
        }
        composable(PAGE_MAP_SEARCH) {
            PageSearch(onBackClick = {
                navController.popBackStack()
            })
        }
    }
}